package top.wuyang.trywork.controller;


import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import top.wuyang.trywork.base.PageBean;
import top.wuyang.trywork.base.R;
import top.wuyang.trywork.entity.TbGame;
import top.wuyang.trywork.service.TbGameService;
import top.wuyang.trywork.vo.PageVO;

@RestController
@RequestMapping("/game")
@RequiredArgsConstructor
public class TbGameController {

    private final TbGameService tbGameService;

    @PostMapping("")
    public R<String> insert(@RequestBody TbGame tbGame) {
        return tbGameService.insert(tbGame);
    }


    @GetMapping("/{pn}/{ps}")
    public R<PageVO<TbGame>> query(TbGame tbGame, @PathVariable("pn") Long pageNumber, @PathVariable("ps") Long pageSize) {
        return tbGameService.query(tbGame, PageBean.instance(pageNumber, pageSize));
    }

    @GetMapping("/{id}")
    public R<TbGame> queryById(@PathVariable("id") Integer id) {
        return tbGameService.queryById(id);
    }

    @PutMapping("")
    public R<String> update(@RequestBody TbGame tbGame) {
        return tbGameService.update(tbGame);
    }

    @DeleteMapping("/{id}")
    public R<String> delete(@PathVariable("id") Integer id) {
        return tbGameService.delete(id);
    }


}
